package com.miyuan.view.replenish;

import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.miyuan.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
import com.miyuan.bean.respone.VendorInfoBean;

/**
 * 补货完成信息修改
 */

public class ModifyReplenishFragment extends Fragment {
    @BindView(R.id.about_us_text)
    TextView replenish_text;

    @BindView(R.id.machine_code)
    TextView machineCode;
    @BindView(R.id.machine_location)
    TextView machineLocation;
    @BindView(R.id.control_code)
    TextView controlCode;
    @BindView(R.id.machine_manager)
    TextView machineManager;
    @BindView(R.id.phone_num)
    TextView phoneNum;
    @BindView(R.id.replenish_money)
    TextView replenishMoney;
    private Unbinder unbinder;
    String v;
    ReplenishFinishFragment replenishFinishFragment;

    public static ModifyReplenishFragment newInstance(VendorInfoBean s) {
        ModifyReplenishFragment modifyReplenishFragment = new ModifyReplenishFragment();
        Bundle bundle = new Bundle();
        bundle.putSerializable("vendorInfoBean", s);
        modifyReplenishFragment.setArguments(bundle);
        return modifyReplenishFragment;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_modify_replenish, container, false);
        unbinder = ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        unbinder.unbind();
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        VendorInfoBean vendorInfoBean = (VendorInfoBean) getArguments().getSerializable("vendorInfoBean");

        machineCode.setText(vendorInfoBean.getNumber());
        machineLocation.setText(vendorInfoBean.getPointName());
        controlCode.setText(vendorInfoBean.getControlNumber());
        phoneNum.setText(vendorInfoBean.getPhone());
        replenishMoney.setText(vendorInfoBean.getShouldRetrieveMoney() + "元");
        machineManager.setText(vendorInfoBean.getName());
    }

    @OnClick(R.id.back_layout)
    void back() {
//        FragmentManager fm = getFragmentManager();
//        FragmentTransaction transaction = fm.beginTransaction();
//        replenishFinishFragment = ReplenishFinishFragment.newInstance(v);
//        transaction.replace(R.id.root_fragment, replenishFinishFragment);
//        transaction.commit();
        getFragmentManager().popBackStack();
    }

    @OnClick(R.id.submit_modify)
    void submitModify() {

    }
}
